const express = require('express')
const history = require('connect-history-api-fallback')
const compression = require('compression')
const path = require('path')

// 监听的端口
const port = 8089

const app = express()

app.use(compression())

app.use(history({
  rewrites: [{
    from: /^\/api\/.*$/,
    to: function(context) {
      return context.parsedUrl.path;
    }
  }]
}))



app.use(express.static(path.join(__dirname, 'dist')))

// app.use('/api/login', (req, res, next) => {
//   res.json({
//     msg: "message"
//   })
// })

app.listen(port, () => {
  console.log(`match listening port in ${port}: http://localhost:${port}`)
})